package com.open.loan.controller;
import java.text.DecimalFormat;	
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.open.common.utils.MD5Utils;
import com.open.loan.domain.req.ReqBankCardModel;
import com.open.loan.domain.req.ReqCodeModel;
import com.open.loan.domain.req.ReqFeedbackModel;
import com.open.loan.domain.req.ReqLoginModel;
import com.open.loan.domain.req.ReqRegisterModel;
import com.open.loan.domain.req.ReqUserContactModel;
import com.open.loan.domain.req.ReqUserInfoModel;
import com.open.loan.domain.rsp.RspHistoryFeedbackModel;
import com.open.loan.domain.rsp.RspUserBasicInfoModel;
import com.open.loan.domain.rsp.RspUserContactInfoModel;
import com.open.loan.utils.ChineseUtils;
import com.open.loan.utils.CookieUtil;
import com.open.loan.utils.HttpUtils;
import com.open.loan.utils.ResponseUtil;
import com.open.loan.utils.sms.ISmsServiceApi;
import com.open.loan.utils.sms.SmsTry;
import com.open.system.domain.LoanApplyDO;
import com.open.system.domain.LoanApplyLogDO;
import com.open.system.domain.LoanBankDO;
import com.open.system.domain.LoanContactDO;
import com.open.system.domain.LoanFeedbackDO;
import com.open.system.domain.LoanShopDO;
import com.open.system.domain.LoanUserDO;
import com.open.system.service.LoanApplyLogService;
import com.open.system.service.LoanApplyService;
import com.open.system.service.LoanBankService;
import com.open.system.service.LoanContactService;
import com.open.system.service.LoanFeedbackService;
import com.open.system.service.LoanShopService;
import com.open.system.service.LoanUserService;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/moblie")
public class VueAllPostController {
	
	private static NumberFormat nf = new DecimalFormat("000000");
	
	@Autowired
	private LoanUserService loanUserService;
	@Autowired
	private LoanContactService loanContactService;
	@Autowired
	private LoanApplyService loanApplyService;
	@Autowired
	private LoanBankService loanBankService;
	@Autowired
	private LoanFeedbackService loanFeedbackService;
	@Autowired
	private ISmsServiceApi smsServiceApi;
	@Autowired
	private LoanApplyLogService loanApplyLogService;
	
	@Autowired
	private LoanShopService loanShopService;
	
	//--注册获取验证码----------------------------------------------------------------------------------------
	@ApiOperation(value="注册获取验证码", notes="")
	@RequestMapping(value ="/getCode",method = RequestMethod.POST)
	public ResponseEntity<ReqCodeModel> getCode(@RequestBody ReqCodeModel model,HttpServletResponse response){
				try {
					if(model==null){
						ResponseUtil.toWrite("300","参数不能为空",null, response);
						return null;
					}
					if(model.getMobile()==null){
						ResponseUtil.toWrite("300","参数不能为空",null, response);
						return null;
					}
					Map<String, Object> map=new HashMap<String, Object>();
					map.put("mobile", model.getMobile());
					List<LoanUserDO>userLists=loanUserService.list(map);
					if(userLists!=null && userLists.size()>0){
						ResponseUtil.toWrite("203","手机号码已经存在",null, response);
						return null;
					}
					String code = nf.format(new Random().nextInt(999999));
					CookieUtil.set(response,model.getMobile()+"_code",code, 1000*60*5);//5分钟
					//Cookie cookie = CookieUtil.get(request,CookieConstant.COOKIE_NAME);
		            //CookieUtil.set(response,CookieConstant.COOKIE_NAME, null, 0);
					//smsServiceApi.sendMessage(model.getMobile(), code,"SMS_143660251");
					 new SmsTry().sendsms(model.getMobile(),"45986",code);
				} catch (Exception e) {
					e.printStackTrace();
					ResponseUtil.toWrite("202","发送失败",null, response);
					return null;
				}
				ResponseUtil.toWrite("200","发送成功",null, response);
				return null;
		}
	
	//--注册接口-----------------------------------------------------------------------------------------
	@ApiOperation(value="注册账号", notes="")
	@RequestMapping(value ="/registerBtn",method = RequestMethod.POST)
	public ResponseEntity<ReqRegisterModel>registerBtn(@RequestBody ReqRegisterModel model,HttpServletResponse response,HttpServletRequest request){
			try {
				if(model==null){
					ResponseUtil.toWrite("300","参数不能为空",null, response);
					return null;
				}
				if(model.getMobile()==null || model.getMobile()==""){
					ResponseUtil.toWrite("301","手机号不能为空",null, response);
					return null;
				}
				if(model.getPassword()==null || model.getPassword()==""){
					ResponseUtil.toWrite("302","密码不能为空",null, response);
					return null;
				}
				if(model.getCode()==null || model.getCode()==""){
					ResponseUtil.toWrite("303","验证码不能为空",null, response);
					return null;
				}
				
				/*Map<String, Object> requestCodeMap=new HashMap<String, Object>();
				requestCodeMap.put("remark4",model.getRequestCode());
				List<LoanUserDO>requestUser=loanUserService.list(requestCodeMap);
				String requestStrCode=null;
				Long remark5=null;
				if(requestUser!=null && requestUser.size()>0){
					LoanUserDO requestDo=requestUser.get(0);
					int idlength=requestDo.getId().toString().length();
					int needLength=6-idlength;
					requestStrCode=getRandString(needLength);
					remark5=requestDo.getId();
				}else {
					ResponseUtil.toWrite("305","该邀请码不存在",null, response);
					return null;
				}*/
				if(model.getShopId()==null || model.getShopId()==""){
					model.setShopId("1");
				}
				LoanShopDO shopEn=loanShopService.get(Long.parseLong(model.getShopId()));
				if(shopEn==null){
					shopEn=loanShopService.get(1L);
				}
				
				
				//邀请码  1就是不显示  0 显示
				if(!"1".equals(shopEn.getRemark3())){
					if(model.getRequestCode()==null || model.getRequestCode()==""){
						ResponseUtil.toWrite("304","门店邀请码不能为空",null, response);
						return null;
					}
					Map<String, Object> requestCodeMap=new HashMap<String, Object>();
					requestCodeMap.put("remark2",model.getRequestCode());
					List<LoanShopDO>requestUser=loanShopService.list(requestCodeMap);
					if(requestUser!=null && requestUser.size()>0){
						
					}else {
						ResponseUtil.toWrite("305","该邀请码不存在",null, response);
						return null;
					}
				}
				//邀请码
				
				//门店上线设置
				Map<String, Object> limitmap=new HashMap<String, Object>();
				limitmap.put("remark2",shopEn.getId());
				Integer count=loanUserService.count(limitmap);
				Integer countShop=0;
				Integer countUser=0;
				if(shopEn.getRemark4()!=null && shopEn.getRemark4()!=""){
					countShop=Integer.parseInt(shopEn.getRemark4());
				}
				if(count!=null){
					countUser=count;
				}
				if(countUser>countShop){
					ResponseUtil.toWrite("203","邀请注册已达上线",null, response);
					return null;
				}
				//门店上线设置
				
				Map<String, Object> map=new HashMap<String, Object>();
				map.put("mobile", model.getMobile());
				List<LoanUserDO>userLists=loanUserService.list(map);
				if(userLists!=null && userLists.size()>0){
					ResponseUtil.toWrite("203","手机号码已存在",null, response);
					return null;
				}
				
				Cookie cookie = CookieUtil.get(request,model.getMobile()+"_code");
				if(cookie==null){
					ResponseUtil.toWrite("204","验证码已过期",null, response);
					return null;
				}
				if(cookie.getValue()==null){
					ResponseUtil.toWrite("204","验证码已过期",null, response);
					return null;
				}
				if(!model.getCode().equals(cookie.getValue())){
					ResponseUtil.toWrite("205","验证码不正确",null, response);
					return null;
				}
				String passwordNew=MD5Utils.encryptByMobile(model.getMobile(),model.getPassword());
				LoanUserDO userDO=new LoanUserDO();
				userDO.setCreateTime(new Date());
				userDO.setMobile(model.getMobile());
				userDO.setPassword(passwordNew);
				userDO.setHasLock(0);
				userDO.setUserType(0);
				userDO.setStatus("0");
				userDO.setRemark2(String.valueOf(shopEn.getId()));
				userDO.setRemark3(shopEn.getShopName());
				//userDO.setRemark4(requestStrCode);//邀请码
				//userDO.setRemark5(String.valueOf(remark5));//邀请人ID
				loanUserService.save(userDO);
				//requestStrCode=requestStrCode+userDO.getId().toString();
				//userDO.setRemark4(requestStrCode);
				//loanUserService.update(userDO);
	            CookieUtil.set(response,model.getMobile()+"_code", null, 0);
				ResponseUtil.toWrite("200","注册成功",null, response);
				return null;
			} catch (Exception e) {
				e.printStackTrace();
				ResponseUtil.toWrite("202","注册失败,错误码30001",null, response);
				return null;
			}
	}
	
	 public static String getRandString(int length){
	        String charList = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	        String rev = "";
	        Random f = new Random();
	        for(int i=0;i<length;i++){
	           rev += charList.charAt(Math.abs(f.nextInt())%charList.length());
	        }
	        return rev;
	    }
	 
	
	//--登录接口---------------------------------------------------------------------------------------
	
	@ApiOperation(value="登录账号", notes="")
	@RequestMapping(value ="/loginBtn",method = RequestMethod.POST)
	public ResponseEntity<ReqLoginModel>loginBtn(@RequestBody ReqLoginModel model,
											  HttpServletRequest request,HttpServletResponse response){
				try {
					if(model==null){
						ResponseUtil.toWrite("300","参数不能为空",null, response);
						return null;
					}
					if(StringUtils.isEmpty(model.getMobile())){
						ResponseUtil.toWrite("301","手机号不能为空",null, response);
						return null;
					}
					if(StringUtils.isEmpty(model.getPassword())){
						ResponseUtil.toWrite("302","密码不能为空",null, response);
						return null;
					}
					Map<String, Object> map=new HashMap<String, Object>();
					map.put("mobile", model.getMobile());
					LoanUserDO userDO=new LoanUserDO();
					List<LoanUserDO>userLists=loanUserService.list(map);
					if(userLists==null){
						ResponseUtil.toWrite("203","手机号不存在",null, response);
						return null;
					}
					if(userLists!=null && userLists.size()==0){
						ResponseUtil.toWrite("203","手机号不存在",null, response);
						return null;
					}
					for (int i = 0; i < userLists.size(); i++) {
						userDO=userLists.get(0);
					}
					String passwordNew=MD5Utils.encryptByMobile(model.getMobile(),model.getPassword());
					if(!passwordNew.equals(userDO.getPassword())){
						ResponseUtil.toWrite("204","密码不正确",null, response);
						return null;
					}
					if(userDO.getHasLock().equals("1")){
						ResponseUtil.toWrite("205","账号已锁定",null, response);
						return null;
					}
					 HttpSession session = request.getSession();
		             session.setAttribute("loanUserDo", userDO);
		             Map<String,String>requestMap=new HashMap<String,String>();
		             requestMap.put("requestCode",userDO.getRemark4());
		             ResponseUtil.toWrite("200","登录成功",requestMap, response);
		             return null;
				} catch (Exception e) {
					e.printStackTrace();
					ResponseUtil.toWrite("202","登录异常",null, response);
					return null;
				}
			}
	
	@ApiOperation(value="退出账号", notes="")
	@RequestMapping(value ="/loginout",method = RequestMethod.GET)
	public ResponseEntity<String>loginout(HttpServletRequest request,HttpServletResponse response){
				try {
					 HttpSession session = request.getSession();
					 LoanUserDO loanUserDo=(LoanUserDO) session.getAttribute("loanUserDo");
						if(loanUserDo==null){
							ResponseUtil.toWrite("200","退出成功",null, response);
							return null;
						}
					 CookieUtil.set(response,loanUserDo.getMobile()+"_code", null, 0);
		             session.setAttribute("loanUserDo", null);
		             ResponseUtil.toWrite("200","退出成功",null, response);
		             return null;
				} catch (Exception e) {
					e.printStackTrace();
					ResponseUtil.toWrite("202","退出异常",null, response);
					return null;
				}
			}
	
	//--忘记密码获取验证码------------------------------------------------------------------------------------
	@ApiOperation(value="忘记密码获取验证码", notes="")
	@RequestMapping(value ="/modifyMobileGetCode",method = RequestMethod.POST)
	public ResponseEntity<ReqCodeModel>modifyMobileGetCode(@RequestBody ReqCodeModel model,HttpServletResponse response){
			try {
				if(model==null){
					ResponseUtil.toWrite("300","参数不能为空",null, response);
					return null;
				}
				if(model.getMobile()==null){
					ResponseUtil.toWrite("301","手机号不能为空",null, response);
					return null;
				}
				String mobile=model.getMobile();
				Map<String, Object> map=new HashMap<String, Object>();
				map.put("mobile", mobile);
				List<LoanUserDO>userLists=loanUserService.list(map);
				if(userLists==null){
					ResponseUtil.toWrite("203","手机号不存在",null, response);
					return null;
				}
				if(userLists!=null && userLists.size()==0){
					ResponseUtil.toWrite("203","手机号不存在",null, response);
					return null;
				}
				String code = nf.format(new Random().nextInt(999999));
				CookieUtil.set(response,mobile+"_ModifyCode",code, 1000*60*5);//5分钟
				//smsServiceApi.sendMessage(mobile, code,"SMS_143660251");
				smsServiceApi.sendMessageNew(mobile,"45986",code);
				ResponseUtil.toWrite("200","发送成功",null, response);
				return null;
			} catch (Exception e) {
				e.printStackTrace();
				ResponseUtil.toWrite("202","发送异常",null, response);
				return null;
			}
	}
	
	//--修改密码-------------------------------------------------------------------------------------------
	@ApiOperation(value="修改密码", notes="")
	@RequestMapping(value ="/modifyPasswordBtn",method = RequestMethod.POST)
	public ResponseEntity<ReqRegisterModel>modifyPasswordBtn( @RequestBody ReqRegisterModel model,HttpServletResponse response,HttpServletRequest request){
			try {
				if(model==null){
					ResponseUtil.toWrite("300","参数不能为空",null, response);
					return null;
				}
				if(model.getMobile()==null){
					ResponseUtil.toWrite("301","手机号不能为空",null, response);
					return null;
				}
				if(StringUtils.isEmpty(model.getPassword())){
					ResponseUtil.toWrite("302","密码不能为空",null, response);
					return null;
				}
				String mobile=model.getMobile();
				String password=model.getPassword();
				String code=model.getCode();
				LoanUserDO userDO=new LoanUserDO();
				Map<String, Object> map=new HashMap<String, Object>();
				map.put("mobile", mobile);
				List<LoanUserDO>userLists=loanUserService.list(map);
				if(userLists==null){
					ResponseUtil.toWrite("203","手机号不存在",null, response);
					return null;
				}
				if(userLists!=null && userLists.size()==0){
					ResponseUtil.toWrite("203","手机号不存在",null, response);
					return null;
				}
				Cookie cookie = CookieUtil.get(request,mobile+"_ModifyCode");
				if(cookie==null){
					ResponseUtil.toWrite("204","验证码已过期",null, response);
					return null;
				}
				if(cookie.getValue()==null){
					ResponseUtil.toWrite("204","验证码已过期",null, response);
					return null;
				}
				if(!cookie.getValue().equals(code)){
					ResponseUtil.toWrite("205","验证码不正确",null, response);
					return null;
				}
				String passwordNew=MD5Utils.encryptByMobile(mobile,password);
				for (int i = 0; i <userLists.size(); i++) {
					userDO=userLists.get(0);
				}
				userDO.setPassword(passwordNew);
				loanUserService.update(userDO);
	            CookieUtil.set(response,mobile+"_ModifyCode", null, 0);
	            ResponseUtil.toWrite("200","修改密码成功",null, response);
	            return null;
			} catch (Exception e) {
				e.printStackTrace();
				ResponseUtil.toWrite("202","修改密码失败",null, response);
				return null;
			}
		}

	//--银行卡认证--------------------------------------------------------------------------------------------------
	@ApiOperation(value="银行卡认证", notes="")
	@RequestMapping(value ="/saveBankInfo",method = RequestMethod.POST)
	public ResponseEntity<ReqBankCardModel>saveBankInfo(HttpServletRequest request,HttpServletResponse response,
			@RequestBody ReqBankCardModel model){
		response.setHeader("Content-type", "text/html;charset=UTF-8");
		if(model==null){
			ResponseUtil.toWrite("300","参数不能为空",null, response);
			return null;
		}
		if(model.getAccountNo()==null || model.getAccountNo()==""){
			ResponseUtil.toWrite("301","银行卡号不能为空",null, response);
			return null;
		}
		if(model.getIdCard()==null || model.getIdCard()==""){
			ResponseUtil.toWrite("302","身份证不能为空",null, response);
			return null;
		}
		if(model.getName()==null || model.getName()==""){
			ResponseUtil.toWrite("303","姓名不能为空",null, response);
			return null;
		}
		boolean hasChinese=new ChineseUtils().hasChinese(model.getName());
		if(!hasChinese){
			ResponseUtil.toWrite("304","姓名格式不合法",null, response);
			return null;
		}
		
		 String name=model.getName();
		 String idCard=model.getIdCard();
		 String accountNo=model.getAccountNo();
		//String mobile=model.getMobile();
		HttpSession session = request.getSession();
		LoanUserDO loanUserDo=(LoanUserDO) session.getAttribute("loanUserDo");
		if(loanUserDo==null){
			ResponseUtil.toWrite("100","请重新登录",null, response);
			return null;
		}
		Map<String, Object> applymap=new HashMap<String, Object>();
		applymap.put("userId", loanUserDo.getId());
		List<LoanApplyDO>applyLists=loanApplyService.list(applymap);
		if(applyLists!=null && applyLists.size()>0){
			LoanApplyDO aDo=applyLists.get(0);
			if("2".equals(aDo.getBankAuth())){
				ResponseUtil.toWrite("109","您已认证过了",null, response);
				return null;
			}
		}
		List<LoanBankDO>bankLists=loanBankService.list(applymap);
		LoanBankDO loanBankDO=null;
		boolean hasBankCard=false;
		if(bankLists!=null && bankLists.size()>0){
			loanBankDO=bankLists.get(0);
			hasBankCard=true;
			/*if(StringUtils.isNotEmpty(loanBankDO.getRemark5()) && "1".equals(loanBankDO.getRemark5())){
				ResponseUtil.toWrite("203","认证过多,请12小时后重试",null, response);
    			return null;
			}*/
		}else {
			loanBankDO=new LoanBankDO();
		}
		
		LoanUserDO userDO=loanUserService.get(loanUserDo.getId());
		String host = "https://bcard3and4.market.alicloudapi.com";
	    String path = "/bankCheck4";
	    String method = "GET";
	    String appcode = "e322234209e04f2ebc1c3f85c84729a8";
	    Map<String, String> headers = new HashMap<String, String>();
	    //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
	    headers.put("Authorization", "APPCODE " + appcode);
	    headers.put("content-type", "text/html;charset=utf-8");
	    Map<String, String> querys = new HashMap<String, String>();
	    querys.put("accountNo",accountNo);
	    querys.put("idCard",idCard);
	    querys.put("mobile",userDO.getMobile());
	    querys.put("name",name);
	    try {
	    	//String urlSend = host + path + "?accountNo=" + querys.get("accountNo") + "&idCard=" + querys.get("idCard")+ "&mobile=" + querys.get("mobile")+ "&name=" + querys.get("name");   //拼接请求链接
	        //URL url = new URL(urlSend);
	        //HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
	        //httpURLConnection.setRequestProperty("Authorization", "APPCODE " + appcode);//格式Authorization:APPCODE (中间是英文空格)
	        //int httpCode = httpURLConnection.getResponseCode();
	    	HttpResponse rspInfo = HttpUtils.doGet(host, path, method, headers, querys);
	    	int httpCode=rspInfo.getStatusLine().getStatusCode();
	    	System.out.println("code=="+httpCode);
	        if(httpCode==200){
	        	//String json = BankReadUtils.read(httpURLConnection.getInputStream());
	        	String json=EntityUtils.toString(rspInfo.getEntity());
	        	JSONObject jsonObj= JSONObject.parseObject(json); 
	        	String status=jsonObj.getString("status");
	        	if("01".equals(status)){
	        		//验证通过
	        		//String msg=jsonObj.getString("msg");
	    	        String idCardObj=jsonObj.getString("idCard");
	    	        String accountNoObj=jsonObj.getString("accountNo");
	    	        String nameObj=jsonObj.getString("name");
	    	        String mobileObj=jsonObj.getString("mobile");
	    	        String bank=jsonObj.getString("bank");
	    	        String sex=jsonObj.getString("sex");
	    	        String area=jsonObj.getString("area");
	    	        String birthday=jsonObj.getString("birthday");
	    	        String cardType=jsonObj.getString("cardType");//借记卡
	    	        String cardName=jsonObj.getString("cardName");//龙卡通
	    	        
	    	        //  0 待完善，1 审核中，2，认证成功 3，认证失败
	    			loanBankDO.setUserId(userDO.getId());
	    			loanBankDO.setRealName(nameObj);
	    			loanBankDO.setCardNo(accountNoObj);
	    			loanBankDO.setIdNo(idCardObj);
	    			loanBankDO.setMoblie(mobileObj);
	    			loanBankDO.setBankName(bank);
	    			loanBankDO.setStatus("2");//['0待完善', '1审核中', '2认证成功', '3认证失败']
	    			loanBankDO.setBankOpenName(cardType+"/"+cardName);
	    			loanBankDO.setCreateTime(new Date());
	    			loanBankDO.setRemark1(area);//地区
	    			loanBankDO.setRemark2(sex);//性别
	    			loanBankDO.setRemark3(birthday);//生日
	    			if(StringUtils.isEmpty(loanBankDO.getRemark4())){
	    				loanBankDO.setRemark4("1");
	    			}else {
						int a=Integer.parseInt(loanBankDO.getRemark4());
						a=a+1;
						loanBankDO.setRemark4(String.valueOf(a));
					}
	    			userDO.setRealName(nameObj);
	    			loanUserService.update(userDO);
	    			if(hasBankCard){
	    				loanBankService.update(loanBankDO);
	    			}else {
	    				loanBankService.save(loanBankDO);
					}
	    			//申请贷款--开始
	    			LoanApplyDO applyDO=new LoanApplyDO();
					Map<String, Object> map=new HashMap<String, Object>();
					map.put("userId",loanUserDo.getId());
					List<LoanApplyDO>applyDOs=loanApplyService.list(map);
					for (int i = 0; i <applyDOs.size(); i++) {
						applyDO=applyDOs.get(0);
					}
					applyDO.setBankAuth("2");//['0待完善', '1审核中', '2认证成功', '3认证失败']
					applyDO.setRealName(nameObj);
					loanApplyService.update(applyDO);
					//申请贷款--结束
	        	}else if ("02".equals(status)) {
	        		ResponseUtil.toWrite("02","验证不通过",null, response);
	    			return null;
				}else if ("202".equals(status)) {
					ResponseUtil.toWrite("202","无法验证",null, response);
	    			return null;
				}else if ("203".equals(status)) {
					loanBankDO.setRemark5("1");
					loanBankService.update(loanBankDO);
					ResponseUtil.toWrite("203","认证过多,请12小时后重试",null, response);
	    			return null;
				}else if ("204".equals(status)) {
					ResponseUtil.toWrite("204","姓名错误",null, response);
	    			return null;
				}else if ("205".equals(status)) {
					ResponseUtil.toWrite("205","身份证号错误",null, response);
	    			return null;
				}else if ("206".equals(status)) {
					ResponseUtil.toWrite("206","银行卡号错误",null, response);
	    			return null;
				}else if ("207".equals(status)){
					ResponseUtil.toWrite("207","电话号码错误",null, response);
	    			return null;
				}
	        	
	        }else if (httpCode==400) {
				ResponseUtil.toWrite("400","URL无效",null, response);
    			return null;
			}else if (httpCode==401) {
				ResponseUtil.toWrite("401","appCode错误",null, response);
    			return null;
			}else if (httpCode==403) {
				ResponseUtil.toWrite("403","今日次数用完",null, response);
    			return null;
			}else if (httpCode==500) {
				ResponseUtil.toWrite("500","API网关错误",null, response);
    			return null;
			}
	    } catch (Exception e) {
	    	e.printStackTrace();
	    	ResponseUtil.toWrite("201","绑定异常",null, response);
			return null;
	    }
		ResponseUtil.toWrite("200","验证成功",null, response);
		return null;
	}
	
	//--意见和反馈-----------------------------------------------------------------------------------------
	@ApiOperation(value="意见反馈", notes="")
	@RequestMapping(value ="/saveFeedback",method = RequestMethod.POST)
	public ResponseEntity<ReqFeedbackModel>saveFeedback(HttpServletRequest request,HttpServletResponse response,
			@RequestBody ReqFeedbackModel model){
		if(model==null){
			ResponseUtil.toWrite("300","参数不能为空",null, response);
			return null;
		}
		if(model.getContent()==null ||model.getContent()==""){
			ResponseUtil.toWrite("300","参数不能为空",null, response);
			return null;
		}
		HttpSession session = request.getSession();
		LoanUserDO loanUserDo=(LoanUserDO) session.getAttribute("loanUserDo");
		if(loanUserDo==null){
			ResponseUtil.toWrite("100","请重新登录",null, response);
			return null;
		}
		try {
			LoanUserDO userDO=loanUserService.get(loanUserDo.getId());
			LoanFeedbackDO feedbackDO=new LoanFeedbackDO();
			feedbackDO.setContent(model.getContent());
			feedbackDO.setUserId(loanUserDo.getId());
			feedbackDO.setRealName(userDO.getRealName());
			feedbackDO.setCreateTime(new Date());
			feedbackDO.setStatus("0");
			loanFeedbackService.save(feedbackDO);
		} catch (Exception e) {
			e.printStackTrace();
			ResponseUtil.toWrite("202","保存失败",null, response);
			return null;
		}
		ResponseUtil.toWrite("200","保存成功",null, response);
		return null;
	}
	//--历史意见和反馈----------------------------------------------------------------------------------
	@ApiOperation(value="历史意见和反馈列表", notes="")
	@RequestMapping(value ="/historyFeedback",method = RequestMethod.GET)
	public ResponseEntity<String>historyFeedback(HttpServletRequest request,HttpServletResponse response){
		HttpSession session = request.getSession();
		LoanUserDO loanUserDo=(LoanUserDO) session.getAttribute("loanUserDo");
		if(loanUserDo==null){
			ResponseUtil.toWrite("100","请重新登录",null, response);
			return null;
		}
		Map<String, Object> map=new HashMap<String,Object>();
		List<RspHistoryFeedbackModel>rspList=new ArrayList<RspHistoryFeedbackModel>();
		try {
			List<LoanFeedbackDO>feedbackLists=loanFeedbackService.list(map);
			SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//这个是你要转成后的时间的格式
			for (int i = 0; i <feedbackLists.size(); i++) {
				RspHistoryFeedbackModel model=new RspHistoryFeedbackModel();
				LoanFeedbackDO feedbackDO=new LoanFeedbackDO();
				feedbackDO=feedbackLists.get(i);
				model.setContent(feedbackDO.getContent());
				if(feedbackDO.getCreateTime()!=null){
					model.setCreateTime(sdf.format(feedbackDO.getCreateTime()));
				}
				model.setDealwithContent(feedbackDO.getRemark1());//remark1 扩展字段-管理员回复信息
				if(feedbackDO.getDealwithTime()!=null){
					model.setDealwithTime(sdf.format(feedbackDO.getDealwithTime()));
				}
				model.setStatus(feedbackDO.getStatus());
				model.setDealwithContent(feedbackDO.getRemark3());
				rspList.add(model);
			}
		} catch (Exception e) {
			e.printStackTrace();
			ResponseUtil.toWrite("202","获取信息失败",null, response);
			return null;
		}
		ResponseUtil.toWrite("200","获取信息成功",rspList, response);
		return null;
	}
	//--保存用户信息------------------------------------------------------------------------------------
	@ApiOperation(value="保存用户信息", notes="")
	@RequestMapping(value ="/saveUserInfo",method = RequestMethod.POST)
	public ResponseEntity<ReqUserInfoModel>saveUserInfo(HttpServletRequest request,HttpServletResponse response,
			@RequestBody ReqUserInfoModel model){
		if(model==null){
			ResponseUtil.toWrite("300","参数不能为空",null, response);
			return null;
		}
		 String companyName=model.getCompanyName();
		 String companyPhone=model.getCompanyPhone();
		 String companyAddress=model.getCompanyAddress();
		 String entryPeriod=model.getEntryPeriod();
		 String companyType=model.getCompanyType();
		 String education=model.getEducation();
		 String marriage=model.getMarriage();
		 String censusAddress=model.getCensusAddress();
		 String remark1=model.getRemark1();
		HttpSession session = request.getSession();
		LoanUserDO loanUserDo=(LoanUserDO) session.getAttribute("loanUserDo");
		if(loanUserDo==null){
			ResponseUtil.toWrite("100","请重新登录",null, response);
			return null;
		}
		if(StringUtils.isEmpty(companyName)){
			ResponseUtil.toWrite("101","公司名称不能为空",null, response);
			return null;
		}
		if(StringUtils.isEmpty(companyPhone)){
			ResponseUtil.toWrite("102","公司电话不能为空",null, response);
			return null;
		}
		if(StringUtils.isEmpty(companyAddress)){
			ResponseUtil.toWrite("103","公司地址不能为空",null, response);
			return null;
		}
		if(StringUtils.isEmpty(companyType)){
			ResponseUtil.toWrite("104","公司性质不能为空",null, response);
			return null;
		}
		if(StringUtils.isEmpty(education)){
			ResponseUtil.toWrite("105","学历不能为空",null, response);
			return null;
		}
		if(StringUtils.isEmpty(marriage)){
			ResponseUtil.toWrite("106","婚姻状况不能为空",null, response);
			return null;
		}
		if(StringUtils.isEmpty(censusAddress)){
			ResponseUtil.toWrite("107","户籍地址不能为空",null, response);
			return null;
		}
		if(StringUtils.isEmpty(entryPeriod)){
			ResponseUtil.toWrite("108","入职年限不能为空",null, response);
			return null;
		}
		/*if(StringUtils.isEmpty(remark1)){
			ResponseUtil.toWrite("109","现住地址不能为空",null, response);
			return null;
		}*/
		LoanUserDO loanUserDO=loanUserService.get(loanUserDo.getId());
		if(loanUserDO==null){
			ResponseUtil.toWrite("201","用户不存在",null, response);
			return null;
		}
		try {
			loanUserDO.setCompanyName(companyName);
			loanUserDO.setCompanyPhone(companyPhone);
			loanUserDO.setCompanyAddress(companyAddress);
			loanUserDO.setEntryPeriod(entryPeriod);
			loanUserDO.setCompanyType(companyType);
			loanUserDO.setEducation(education);
			loanUserDO.setMarriage(marriage);
			loanUserDO.setCensusAddress(censusAddress);
			//loanUserDO.setRemark1(remark1);
			loanUserService.update(loanUserDO);
			//applyDO表----------------------------------开始------------
			LoanApplyDO applyDO=new LoanApplyDO();
			Map<String, Object> map=new HashMap<String, Object>();
			map.put("userId", loanUserDo.getId());
			List<LoanApplyDO>applyList=loanApplyService.list(map);
			
			if(applyList!=null && applyList.size()>0){
				for (int i = 0; i <applyList.size(); i++) {
					applyDO=applyList.get(0);
				}
				applyDO.setUserInfoAuth("2");//['0待完善', '1审核中', '2认证成功', '3认证失败']
				loanApplyService.update(applyDO);
			}else {
				applyDO.setUserId(loanUserDO.getId());
				applyDO.setUserInfoAuth("2");//['0待完善', '1审核中', '2认证成功', '3认证失败']
				applyDO.setContactAuth("0");
				applyDO.setBankAuth("0");
				applyDO.setFaceAuth("0");
				applyDO.setCreditAuth("0");
				applyDO.setStatus("0");//借款状态 0 申请中, 1 待放款,2，放款中，3已放款  4，还款中，5已还清
				applyDO.setBillingtype("0");
				applyDO.setBillingtypeCard("0");
				applyDO.setCreateTime(new Date());
				applyDO.setRemark6(loanUserDO.getMobile());
				applyDO.setRemark7(loanUserDO.getRemark2());
				applyDO.setRemark8(loanUserDO.getRemark3());
				loanApplyService.save(applyDO);
			}
			//applyDO表----------------------------------结束------------
			//applyLog表---------------------------------开始------------
			LoanApplyLogDO applyLogDO=loanApplyLogService.getLastNewData(map);
			if((applyLogDO!=null && "5".equals(applyLogDO.getStatus()))||applyLogDO==null){
				LoanApplyLogDO applyDo=new LoanApplyLogDO();
				applyDo.setUserId(loanUserDO.getId());
				applyDo.setStatus("0");
				applyDo.setCreateTime(new Date());
				if(applyDo.getRealName()!=null && applyDo.getRealName()!=""){
					applyDo.setRealName(loanUserDo.getRealName());
				}else {
					applyDo.setRealName(loanUserDo.getMobile());
				}
				loanApplyLogService.save(applyDo);
			}
			//applyLog表---------------------------------结束------------
		} catch (Exception e) {
			e.printStackTrace();
			ResponseUtil.toWrite("202","保存异常，错误码30001",null, response);
			return null;
		}
		ResponseUtil.toWrite("200","保存成功",null, response);
		return null;
	}
	//--保存联系人信息--------------------------------------------------------------------------------------
	@ApiOperation(value="用户联系人信息", notes="")
	@RequestMapping(value ="/saveUserContactInfo",method = RequestMethod.POST)
	public ResponseEntity<ReqUserContactModel>saveUserContactInfo(HttpServletRequest request,HttpServletResponse response,
				 @RequestBody ReqUserContactModel model){
		
				if(model==null){
					ResponseUtil.toWrite("300","参数不能为空",null, response);
					return null;
				}
				if(model.getcMoblie1()==null || model.getcMoblie2()==null ||model.getcMoblie3()==null){
					ResponseUtil.toWrite("301","手机号码不能为空",null, response);
					return null;
				}
				if(model.getcName1()==null || model.getcName2()==null ||model.getcName3()==null){
					ResponseUtil.toWrite("302","真实姓名不能为空",null, response);
					return null;
				}
				boolean mobile1=new ChineseUtils().isChinaPhoneLegal(model.getcMoblie1());
				boolean mobile2=new ChineseUtils().isChinaPhoneLegal(model.getcMoblie2());
				boolean mobile3=new ChineseUtils().isChinaPhoneLegal(model.getcMoblie3());
				if(!mobile1){
					ResponseUtil.toWrite("305","第一个手机号不合法",null, response);
					return null;
				}
				if(!mobile2){
					ResponseUtil.toWrite("306","第二个手机号不合法",null, response);
					return null;
				}
				if(!mobile3){
					ResponseUtil.toWrite("307","第三个手机号不合法",null, response);
					return null;
				}
				if(model.getcMoblie1().equals(model.getcMoblie2())){
					ResponseUtil.toWrite("308","一,二手机号不可相同",null, response);
					return null;
				}
				if(model.getcMoblie1().equals(model.getcMoblie3())){
					ResponseUtil.toWrite("308","一,三手机号不可相同",null, response);
					return null;		
				}
				if(model.getcMoblie2().equals(model.getcMoblie3())){
					ResponseUtil.toWrite("308","二,三手机号不可相同",null, response);
					return null;
				}
				
				boolean name1=new ChineseUtils().hasChinese(model.getcName1());
				boolean name2=new ChineseUtils().hasChinese(model.getcName2());
				boolean name3=new ChineseUtils().hasChinese(model.getcName3());
				if(!name1 || !name2 || !name3){
					ResponseUtil.toWrite("303","存在姓名不合法",null, response);
					return null;
				}
				if(model.getcRelationship1()==null || model.getcRelationship2()==null ||model.getcRelationship3()==null){
					ResponseUtil.toWrite("304","关系不能为空",null, response);
					return null;
				}
				 String cName1=model.getcName1();
				 String cMoblie1=model.getcMoblie1();
				 String cRelationship1=model.getcRelationship1();
				 String cName2=model.getcName2();
				 String cMoblie2=model.getcMoblie2();
				 String cRelationship2=model.getcRelationship2();
				 String cName3=model.getcName3();
				 String cMoblie3=model.getcMoblie3();
				 String cRelationship3=model.getcRelationship3();
				HttpSession session = request.getSession();
				LoanUserDO loanUserDo=(LoanUserDO) session.getAttribute("loanUserDo");
				if(loanUserDo==null){
					ResponseUtil.toWrite("100","请重新登录",null, response);
					return null;
				}
				LoanUserDO loanUserDO=loanUserService.get(loanUserDo.getId());
				try {
				Map<String, Object> map=new HashMap<String, Object>();
				map.put("userId",loanUserDO.getId());
				List<LoanContactDO>contactList=loanContactService.list(map);
				if(contactList!=null && contactList.size()>0){
					LoanContactDO contactDO=contactList.get(0);
					contactDO.setUserId(loanUserDO.getId());
					contactDO.setCreateTime(new Date());
					contactDO.setcName1(cName1);
					contactDO.setcName2(cName2);
					contactDO.setcName3(cName3);
					contactDO.setcMoblie1(cMoblie1);
					contactDO.setcMoblie2(cMoblie2);
					contactDO.setcMoblie3(cMoblie3);
					contactDO.setcRelationship1(cRelationship1);
					contactDO.setcRelationship2(cRelationship2);
					contactDO.setcRelationship3(cRelationship3);
					contactDO.setRemark1(loanUserDO.getMobile());
					loanContactService.update(contactDO);
				}else{
					LoanContactDO contactDO=new LoanContactDO();
					contactDO.setUserId(loanUserDO.getId());
					contactDO.setCreateTime(new Date());
					contactDO.setcName1(cName1);
					contactDO.setcName2(cName2);
					contactDO.setcName3(cName3);
					contactDO.setcMoblie1(cMoblie1);
					contactDO.setcMoblie2(cMoblie2);
					contactDO.setcMoblie3(cMoblie3);
					contactDO.setcRelationship1(cRelationship1);
					contactDO.setcRelationship2(cRelationship2);
					contactDO.setcRelationship3(cRelationship3);
					contactDO.setRemark1(loanUserDO.getMobile());
					loanContactService.save(contactDO);
				}
					LoanApplyDO applyDO=new LoanApplyDO();
					List<LoanApplyDO>applyDOs=loanApplyService.list(map);
					for (int i = 0; i <applyDOs.size(); i++) {
						applyDO=applyDOs.get(0);
					}
					applyDO.setContactAuth("2");//['0待完善', '1审核中', '2认证成功', '3认证失败']
					loanApplyService.update(applyDO);
					ResponseUtil.toWrite("200","保存成功",null, response);
					return null;
				} catch (Exception e) {
					e.printStackTrace();
					ResponseUtil.toWrite("202","保存失败,错误码30001",null, response);
					return null;
				}
		}
	//-------------------------------------------------------------------------------------------------------
	//回显用户信息---
	@ApiOperation(value="回调显示用户基础信息", notes="")
	@RequestMapping(value ="/getUserBasisInfo",method = RequestMethod.GET)
	public ResponseEntity<String>getUserBasisInfo(HttpServletRequest request,HttpServletResponse response){
		HttpSession session = request.getSession();
		LoanUserDO loanUserDo=(LoanUserDO) session.getAttribute("loanUserDo");
		if(loanUserDo==null){
			ResponseUtil.toWrite("100","请重新登录",null, response);
			return null;
		}
		Map<String, Object> map=new HashMap<String,Object>();
		RspUserBasicInfoModel model=null;
		try {
			model=new RspUserBasicInfoModel();
			loanUserDo =loanUserService.get(loanUserDo.getId());
			model.setCompanyName(loanUserDo.getCompanyName());
			model.setCompanyAddress(loanUserDo.getCompanyAddress());
			model.setCompanyType(loanUserDo.getCompanyType());
			model.setMarriage(loanUserDo.getMarriage());
			model.setEducation(loanUserDo.getEducation());
			model.setEntryPeriod(loanUserDo.getEntryPeriod());
			model.setCensusAddress(loanUserDo.getCensusAddress());
			model.setCompanyPhone(loanUserDo.getCompanyPhone());
		} catch (Exception e) {
			e.printStackTrace();
			ResponseUtil.toWrite("202","回显信息失败",null, response);
			return null;
		}
		ResponseUtil.toWrite("200","回显信息成功",model, response);
		return null;
	}
	
	//---回显联系人信息------------------------------------------------------------------------------------------
	@ApiOperation(value="回调用户联系人信息", notes="")
	@RequestMapping(value ="/getUserContactInfo",method = RequestMethod.GET)
	public ResponseEntity<String>getUserContactInfo(HttpServletRequest request,HttpServletResponse response){
		HttpSession session = request.getSession();
		LoanUserDO loanUserDo=(LoanUserDO) session.getAttribute("loanUserDo");
		if(loanUserDo==null){
			ResponseUtil.toWrite("100","请重新登录",null, response);
			return null;
		}
		Map<String, Object> map=new HashMap<String,Object>();
		map.put("userId", loanUserDo.getId());
		try {
			List<LoanContactDO>loanContactDOs=loanContactService.list(map);
			RspUserContactInfoModel model=null;
			for (int i = 0; i <loanContactDOs.size(); i++) {
				model=new RspUserContactInfoModel();
				LoanContactDO contactDO=loanContactDOs.get(0);
				model.setcMoblie1(contactDO.getcMoblie1());
				model.setcMoblie2(contactDO.getcMoblie2());
				model.setcMoblie3(contactDO.getcMoblie3());
				model.setcName1(contactDO.getcName1());
				model.setcName2(contactDO.getcName2());
				model.setcName3(contactDO.getcName3());
				model.setcRelationship1(contactDO.getcRelationship1());
				model.setcRelationship2(contactDO.getcRelationship2());
				model.setcRelationship3(contactDO.getcRelationship3());
			}
			ResponseUtil.toWrite("200","回显信息成功",model, response);
			return null;
		} catch (Exception e) {
			e.printStackTrace();
			ResponseUtil.toWrite("202","会显信息失败",null, response);
			return null;
		}
	}
	
	/**
	 * 邀请码是否显示接口
	 */
	@ApiOperation(value="邀请码是否显示接口", notes="")
	@RequestMapping(value ="/hasShowCode",method = RequestMethod.POST)
	public ResponseEntity<ReqRegisterModel>hasShowCode(@RequestBody ReqRegisterModel model,HttpServletRequest request,HttpServletResponse response){
		try {	
			if(StringUtils.isNotEmpty(model.getShopId())){
				LoanShopDO loanShopDO=loanShopService.get(Long.parseLong(model.getShopId()));
				Map<String,Object>map=new HashMap<String,Object>();
				Integer hasShow=0;
				if(StringUtils.isNotEmpty(loanShopDO.getRemark3()) &&"1".equals(loanShopDO.getRemark3())){
					hasShow=1;
				}else {
					hasShow=0;
				}
				map.put("hasShow",hasShow);
				ResponseUtil.toWrite("200","邀请码是否成功",map, response);
				return null;
			}else {
				ResponseUtil.toWrite("202","店铺信息不存在",null, response);
				return null;
			}
		} catch (Exception e) {
			e.printStackTrace();
			ResponseUtil.toWrite("202","邀请码是否失败",null, response);
			return null;
		}
	}
	
	
	/**
	 * 是否显示店铺图片
	 */
	@ApiOperation(value="是否显示店铺图片", notes="")
	@RequestMapping(value ="/hasShowShopImage",method = RequestMethod.POST)
	public ResponseEntity<ReqRegisterModel>hasShowShopImage(@RequestBody ReqRegisterModel model,HttpServletRequest request,HttpServletResponse response){
		try {	
			if(StringUtils.isNotEmpty(model.getShopId())){
				LoanShopDO loanShopDO=loanShopService.get(Long.parseLong(model.getShopId()));
				Map<String,Object>map=new HashMap<String,Object>();
				String shopImage=null;
				String shopName=null;
				if(loanShopDO!=null){
					shopImage=loanShopDO.getShopImage();
					shopName=loanShopDO.getShopName();
				}
				map.put("shopImage",shopImage);
				map.put("shopName",shopName);
				ResponseUtil.toWrite("200","信息获取成功",map, response);
				return null;
			}else {
				ResponseUtil.toWrite("202","信息获取不存在",null, response);
				return null;
			}
		} catch (Exception e) {
			e.printStackTrace();
			ResponseUtil.toWrite("202","店铺信息获取失败",null, response);
			return null;
		}
	}
	
	
	/**
	 * 授信接口
	 */
	@ApiOperation(value=" 授信接口", notes="")
	@RequestMapping(value ="/getCreditInfo",method = RequestMethod.GET)
	public ResponseEntity<ReqRegisterModel>getCreditInfo(HttpServletRequest request,HttpServletResponse response){
		try {	
			HttpSession session = request.getSession();
			LoanUserDO loanUserDo=(LoanUserDO) session.getAttribute("loanUserDo");
			if(loanUserDo==null){
				ResponseUtil.toWrite("100","请重新登录",null, response);
				return null;
			}
			loanUserDo=loanUserService.get(loanUserDo.getId());
			Map<String, Object> remap=new HashMap<String,Object>();
			remap.put("userId", loanUserDo.getId());
			LoanBankDO bankDO=new LoanBankDO();
			List<LoanBankDO>banks=loanBankService.list(remap);
			Long shopId=1L;
			if(StringUtils.isNotEmpty(loanUserDo.getRemark2())){
				shopId=Long.parseLong(loanUserDo.getRemark2());
			}
			LoanShopDO shop=loanShopService.get(shopId);
			Date currentTime = new Date();
		    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		    String dateString = formatter.format(currentTime);
		    Map<String,Object>map=new HashMap<String,Object>();
			if(banks!=null && banks.size()>0){
				bankDO=banks.get(0);
				if(shop!=null){
					if(StringUtils.isNotEmpty(shop.getRemark5())){
						String creditInfo=shop.getRemark5();
						//备注：身份证标识: AAAAA , 姓名: BBBBB , 手机号: CCCCC , 时间: DDDDD 】
						creditInfo=creditInfo.replaceAll("AAAAA", bankDO.getIdNo());
						creditInfo=creditInfo.replaceAll("BBBBB", bankDO.getRealName());
						creditInfo=creditInfo.replaceAll("CCCCC", bankDO.getMoblie());
					    creditInfo=creditInfo.replaceAll("DDDDD", dateString);
					    creditInfo=creditInfo.replaceAll("EEEEE", loanUserDo.getCensusAddress());
						map.put("creditInfo",creditInfo);
						map.put("createTime", dateString);
					}else {
						map.put("creditInfo",null);
						map.put("createTime", dateString);
					}
				}else {
					ResponseUtil.toWrite("201","店铺不存在或者已下架！",map, response);
					return null;
				}
			}else {
				ResponseUtil.toWrite("201","您还未实名！",map, response);
				return null;
			}
			
			ResponseUtil.toWrite("200","征信信息获取成功",map, response);
			return null;
		} catch (Exception e) {
			e.printStackTrace();
			ResponseUtil.toWrite("202","征信信息获取失败",null, response);
			return null;
		}
	}
	
	
	/**
	 * 委托担保申请
	 */
	@ApiOperation(value=" 委托担保申请", notes="")
	@RequestMapping(value ="/getGuaranteeApplyInfo",method = RequestMethod.GET)
	public ResponseEntity<ReqRegisterModel>getGuaranteeApplyInfo(HttpServletRequest request,HttpServletResponse response){
		try {	
			HttpSession session = request.getSession();
			LoanUserDO loanUserDo=(LoanUserDO) session.getAttribute("loanUserDo");
			if(loanUserDo==null){
				ResponseUtil.toWrite("100","请重新登录",null, response);
				return null;
			}
			loanUserDo=loanUserService.get(loanUserDo.getId());
			Map<String, Object> remap=new HashMap<String,Object>();
			remap.put("userId", loanUserDo.getId());
			LoanBankDO bankDO=new LoanBankDO();
			List<LoanBankDO>banks=loanBankService.list(remap);
			Long shopId=1L;
			if(StringUtils.isNotEmpty(loanUserDo.getRemark2())){
				shopId=Long.parseLong(loanUserDo.getRemark2());
			}
			LoanShopDO shop=loanShopService.get(shopId);
			Date currentTime = new Date();
		    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		    String dateString = formatter.format(currentTime);
		    Map<String,Object>map=new HashMap<String,Object>();
			if(banks!=null && banks.size()>0){
				bankDO=banks.get(0);
				if(shop!=null){
					if(StringUtils.isNotEmpty(shop.getRemark6())){
						String creditInfo=shop.getRemark6();
						//备注：身份证标识: AAAAA , 姓名: BBBBB , 手机号: CCCCC , 时间: DDDDD 】
						creditInfo=creditInfo.replaceAll("AAAAA", bankDO.getIdNo());
						creditInfo=creditInfo.replaceAll("BBBBB", bankDO.getRealName());
						creditInfo=creditInfo.replaceAll("CCCCC", bankDO.getMoblie());
					    creditInfo=creditInfo.replaceAll("DDDDD", dateString);
					    creditInfo=creditInfo.replaceAll("EEEEE", loanUserDo.getCensusAddress());
						map.put("creditInfo",creditInfo);
						map.put("createTime", dateString);
					}else {
						map.put("creditInfo",null);
						map.put("createTime", dateString);
					}
				}else {
					ResponseUtil.toWrite("201","店铺不存在或者已下架！",map, response);
					return null;
				}
			}else {
				ResponseUtil.toWrite("201","您还未实名！",map, response);
				return null;
			}
			
			ResponseUtil.toWrite("200","征信信息获取成功",map, response);
			return null;
		} catch (Exception e) {
			e.printStackTrace();
			ResponseUtil.toWrite("202","征信信息获取失败",null, response);
			return null;
		}
	}
	
}
